// var i;
// var AL_GAME_HUA_Define = require("./AL_GAME_HUA_Define");
// var AL_GAME_HUA_GameData = require("./AL_GAME_HUA_GameData");
// var l = cc._decorator;
// var u = l.ccclass;
// var p =
//     (l.property,
//     l.menu,
//     (function (e) {
//         function t() {
//             var t = (null !== e && e.apply(this, arguments)) || this;
//             t.icon = null;
//             t.label = null;
//             return t;
//         }
//         __extends(t, e);
//         t.prototype.onLoad = function () {
//             var e = this;
//             this.icon = this.node.getChildByName("gold");
//             this.label = this.node.getChildByName("label_number").getComponent(cc.Label);
//             this.label.string = AL_GAME_HUA_GameData.GameData.getInstance().huoqu_xingxing_shuliang().toString();
//             AL_APP_SDK_MANAGER.on(
//                 AL_GAME_HUA_Define.GameEvent.ADD_STAR_NUM,
//                 function () {
//                     e.label.string = AL_GAME_HUA_GameData.GameData.getInstance().huoqu_xingxing_shuliang().toString();
//                 },
//                 this
//             );
//         };
//         t.prototype.onDestroy = function () {
//             AL_APP_SDK_MANAGER.off(this);
//         };
//         return __decorate([u], t);
//     })(cc.Component));
// exports.default = p;


const AL_GAME_HUA_Define = require("./AL_GAME_HUA_Define");
const AL_GAME_HUA_GameData = require("./AL_GAME_HUA_GameData");
const { ccclass, property, menu } = cc._decorator;

/**
 * @class GoldStarComponent
 * @extends cc.Component
 * 这是一个用于处理金币和星星显示更新的组件
 */
@ccclass
class GoldStarComponent extends cc.Component {

    constructor() {
        super();
        // 图标节点
        this.icon = null;
        // 标签节点
        this.label = null;
    }

    /**
     * @method onLoad
     * 初始化组件属性
     */
    onLoad() {
        this.icon = this.node.getChildByName("gold");
        this.label = this.node.getChildByName("label_number").getComponent(cc.Label);
        this.update_Star_Number();

        AL_APP_SDK_MANAGER.on(
            AL_GAME_HUA_Define.GameEvent.ADD_STAR_NUM,
            this.update_Star_Number,
            this
        );
    }

    /**
     * @method onDestroy
     * 组件销毁前的清理工作
     */
    onDestroy() {
        AL_APP_SDK_MANAGER.off(this);
    }

    /**
     * @method update_Star_Number
     * 更新显示的星星数量
     */
    update_Star_Number() {
        this.label.string = AL_GAME_HUA_GameData.GameData.getInstance().huoqu_xingxing_shuliang().toString();
    }
}

exports.default = GoldStarComponent;